import {
  BatchMetricsValuesResp,
  HeatmapResp,
  LabeledMetricsValuesResp,
  MetricsValuesResp,
  QueryBatchMetricsConditionReq,
  QueryMetricsConditionReq,
  QueryTopNConditionReq,
  SortMetrics,
} from './model/apmModel';
import { maintenanceHttp } from '/@/utils/http/axios';

enum Api {
  GET_TOP_N_SORTED_METRICS = '/v1/maintenance/apm/sortMetrics',
  GET_LABELED_METRICS_VALUES = '/v1/maintenance/apm/readLabeledMetricsValues',
  GET_HEATMAP = '/v1/maintenance/apm/readHeatMap',
  GET_SINGLE_METRICS_VALUE = '/v1/maintenance/apm/readMetricsValue',
  GET_LIST_METRICS_VALUE = '/v1/maintenance/apm/readMetricsValues',
  GET_BATCH_METRICS_VALUE = '/v1/maintenance/apm/readBatchMetricsValues',
}

export const getTopNSortedMetrics = (params: QueryTopNConditionReq) => {
  //  获取度量指标Top N
  return maintenanceHttp.post<SortMetrics[]>({ url: Api.GET_TOP_N_SORTED_METRICS, params });
};

export const getLabeledMetricsValues = (params: QueryMetricsConditionReq) => {
  //  获取标签度量值
  return maintenanceHttp.post<LabeledMetricsValuesResp>({
    url: Api.GET_LABELED_METRICS_VALUES,
    params,
  });
};

export const getHeatmap = (params: QueryMetricsConditionReq) => {
  //  获取热力图数据
  return maintenanceHttp.post<HeatmapResp>({ url: Api.GET_HEATMAP, params });
};

export const getSingleMetricsValues = (params: QueryMetricsConditionReq) => {
  // 获取单个度量值
  return maintenanceHttp.post<number>({ url: Api.GET_SINGLE_METRICS_VALUE, params });
};

export const getListMetricsValues = (params: QueryMetricsConditionReq) => {
  //  '获取序列度量值
  return maintenanceHttp.post<MetricsValuesResp>({ url: Api.GET_LIST_METRICS_VALUE, params });
};

export const getBatchMetricsValues = (params: QueryBatchMetricsConditionReq) => {
  // '获取批量度量值
  return maintenanceHttp.post<BatchMetricsValuesResp>({ url: Api.GET_BATCH_METRICS_VALUE, params });
};
